import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider

# 中文显示
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
plt.rcParams['axes.unicode_minus'] = False

# 演示有界函数与无穷小的乘积：f(x) = x·sin(1/x) (x→0)
x = np.linspace(-0.1, 0.1, 1000)
f_x = x * np.sin(1/x)

plt.figure(figsize=(10, 6))
plt.plot(x, f_x, label='f(x) = x·sin(1/x)')
plt.axhline(y=0, color='r', linestyle='--', label='y=0')
plt.xlim(-0.1, 0.1)
plt.ylim(-0.1, 0.1)
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title('有界函数与无穷小的乘积')
plt.legend()
plt.grid(True)
plt.show()